<template>
  <view
    class="content"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#FFFFFF"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text" @click="down">灵感塔</view>
      <view class="head_right">
        <u-icon
          size="20"
          name="plus"
          color="#EEEEEE"
          @click="createFn"
        ></u-icon>
      </view>
    </view>

    <scroll-view
      :style="{
        height: scrollHeihgt + 'px',
      }"
      :scroll-y="true"
      @scroll="scroll"
      @scrolltolower="scrolltolower"
    >
      <lingDD :list="list" :type="type"></lingDD>
    </scroll-view>


    <floatingBall></floatingBall>
  </view>
</template>

<script>
import lingDD from "@/components/lingDD.vue";
export default {
  components: {
    lingDD,
  },

  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      scrollHeihgt: 0,
      list: [],
      page: 1,
      list_page: 0,
    };
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度
    const windowHeihgt = statusBarHeight.windowHeight;
    this.statusBarHeight = statusBarHeight.statusBarHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
        })
        .exec();
    });

    this.$nextTick(() => {
      const query = uni.createSelectorQuery().in(this);
      query.select(".head").fields({
        size: true,
      });
      query.exec((data) => {
        let sum = 0;
        data.forEach((item) => {
          sum += item.height;
        });
        this.scrollHeihgt = windowHeihgt - sum - this.statusBarHeight;
      });
    });
    // this.getList()
  },
  onLoad(options) {
    this.type = options.type;
  },
  onShow: function () {
    this.list = []
    this.page = 1;
    this.last_page = 0;
    this.getList();
  },
  methods: {
    // 跳转创建页面
    createFn() {
      uni.navigateTo({
        url: "/pages/bigResult/minute_create?type=2",
      });
    },
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    scroll() {},
    scrolltolower() {
      if (this.page == this.last_page || this.last_page == 0) {
      } else {
        this.page++;
       this.getList()
      }
      console.log("触发");
    },
    getList() {
      this.$http
        .usergongnengLingganta({page:this.page})
        .then((res) => {
          this.list =this.list.concat(res.data.list.data) ;
          console.log(this.list, "灵感塔");
        })
        .catch((error) => {
          uni.$u.toast(error);
        });
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  position: fixed;
  box-sizing: border-box;
  background: url("/static/images/index.png") no-repeat;
  background-size: 100% 100%;
  padding-bottom: 40rpx;
}

.head {
  width: 100%;
  padding: 18rpx 30rpx 47rpx;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  z-index: 99;

  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .head_right {
    position: absolute;
    right: 30rpx;
    font-size: 30rpx;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    color: #55b877;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #ffffff;
  }
}
</style>